<template>
	<view>
		<tab-nav :orderStaArr="orderStaArr" :orderStaIndex="orderStaIndex" @switchStatus="switchStatus" colType="redBg"></tab-nav>
		<view class="yhqList">
			<template v-if="hasYhqFlag">
				<yhq-list :yhqList="yhqList" @yhqLq="yhqLq"></yhq-list>
				<loading-view :loading="loading"></loading-view>
			</template>
			<template v-else-if="hasYhqFlag == false">
				<no-data></no-data>
			</template>
		</view>
		<view class="botBtn">
			<view class="innerBtn" @tap="goMyYhqList">我的优惠券</view>
		</view>
	</view>
</template>

<script>
	import TabNav from '@/components/tab-nav/tab-nav'
	import YhqList from '../../index/components/YhqList.vue'
	import yhqMixin from '@/utils/yhqMixin.js'
	export default {
		components:{
			YhqList
		},
		mixins:[yhqMixin],
		data(){
			return{
				orderStaArr:[
					{id:'zx',name:'个体咨询'},
					{id:'cp',name:'个体测评'},
				],
				orderStaIndex:0,
				type:''
			}
		},
		onLoad(options){
			this.orderStaIndex = options.currIndex == undefined ? 0 : Number(options.currIndex);
			this.type = options.type == undefined ? 'zx' : options.type;
			this.getCanUseYhqList(this.type,'list');
		},
		onPullDownRefresh : function(){
			this.initParams();
			uni.stopPullDownRefresh();
		},
		onReachBottom : function(){
			if( !this.loading){
				this.getCanUseYhqList(this.type,'list');
			}
		},
		methods:{
			yhqLq(id){
				this.goLqYhq(id,this.type);
			},
			switchStatus(index,id){
				this.orderStaIndex = index;
				this.type = id;
				this.initParams();
			},
			initParams(){
				this.nowPageYhq = 1;
				this.loading = false;
				this.yhqList = [];
				this.getCanUseYhqList(this.type,'list');
			},
			goMyYhqList(){
				uni.navigateTo({
					url:'/pages/subMine/myYhq/myYhq'
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #F6F6F6;
		padding-bottom: 140rpx;
	}
	.yhqList{
		padding: 0 20rpx;
	}
	.botBtn{
		width: 100%;
		position: fixed;
		left: 0;
		bottom: 30rpx;
		z-index: 3;
		.innerBtn{
			height: 90rpx;
			line-height: 90rpx;
			background: $pss-color-primary_1;
			margin: 0 20rpx;
			border-radius: 50rpx;
			text-align: center;
			color: #fff;
			font-size: 30rpx;
		}
	}
</style>